package com.tjetc.util;

import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class R {
    private Integer code;//200成功 其他代表失败
    private String msg;//响应消息
    private Object data;//响应数据

    public static R genR(Integer code,String msg,Object data){
        return new R(code, msg, data);
    }
    //如果成功 code=200 msg=操作成功
    public static R ok(Object data){
        return genR(200, "操作成功", data);
    }

    public static R ok(){
        return ok(null);
    }
    //如果失败 code！=200  data=null
    public static R fail(Integer code , String msg){
        return genR(code, msg,  null);
    }
}
